<template>
  <div style="background-color: white !important">
    <el-row align="middle">
      <el-col :span="1" />
      <el-col :span="23">
        <el-row style="width: 100%">
          <el-col :span="22">
            <!-- <el-row class="mt-15" justify="center">
              <span class="h1-font">采购部月生产报告填写</span>
            </el-row> -->
            <el-row class="mt-15">
              <span class="h2-font">
                报告期：<el-date-picker
                  style="width: 140px"
                  v-model="reportMonth"
                  @change="reportMonthChange"
                  type="month"
                  format="YYYY年M月" />
              </span>
              <!-- <span
                v-if="(employee.empRole === 2 || employee.empRole === 3)"
                class="h2-font"
                style="margin-left: 20px">
                配置项目：
                <el-select
                  v-model="selectProjectIdData"
                  @change="selectProjectChange"
                  @blur="saveReportProject"
                  multiple
                  filterable
                  :reserve-keyword="false"
                  collapse-tags
                  :max-collapse-tags="0"
                  placeholder="请选择项目">
                  <el-option
                    v-for="item in projectData"
                    :label="'[' + item.projectCode + ']' + item.projectName"
                    :value="item.projectId"></el-option>
                </el-select>
              </span> -->
            </el-row>
            <el-row class="mt-15" v-if="employee.empRole === 2 || employee.empRole === 3">
              <el-collapse style="width: 100%" v-model="collapseActiveNames" accordion>
                <el-collapse-item name="1">
                  <template #title>
                    <el-row justify="space-between" style="width: 100%">
                      <span class="h3-font">项目填报情况</span>
                      <el-text type="info">详情</el-text>
                    </el-row>
                  </template>
                  <el-table
                    v-if="collapseActiveNames === '1'"
                    header-cell-class-name="header-cell"
                    :data="reportProjectData"
                    size="small"
                    border>
                    <el-table-column type="index" label="序号" width="60" align="center" />
                    <el-table-column label="项目名称" header-align="center">
                      <template #default="scope">
                        <span>{{ "[" + scope.row.projectCode + "]" + scope.row.projectName }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column label="填报情况" header-align="center" width="250">
                      <template #default="scope">
                        <el-row>
                          <span v-for="item in scope.row.reportLogList">{{ item.modifyDatetime + "：" + item.empName }}</span>
                        </el-row>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-collapse-item>
              </el-collapse>
            </el-row>
            <el-row class="mt-15"><span class="h2-font">一、部室项目执行情况</span></el-row>
            <el-row class="mt-15"><span class="h3-font">1、项目详细</span></el-row>
            <el-row class="mt-15">
              <el-table
                header-cell-class-name="header-cell"
                :data="projectDetailsData"
                v-loading="isLoading"
                element-loading-text="加载中 . . ."
                element-loading-background="rgba(0, 0, 0, 0.8)"
                size="small"
                border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectStage" label="项目阶段" header-align="center" width="150">
                  <template #default="scope">
                    <el-select
                      style="width: 100%"
                      v-model="scope.row.projectStage"
                      filterable
                      allow-create
                      :reserve-keyword="false"
                      placeholder="请选择或填写"
                      clearable>
                      <el-option label="总承包" value="总承包" />
                      <el-option label="管理包" value="管理包" />
                      <el-option label="投标报价" value="投标报价" />
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="采购经理" header-align="center" width="250">
                  <template #default="scope">
                    <el-select
                      v-if="employee.empRole === 2 || employee.empRole === 3"
                      style="width: 100%"
                      v-model="scope.row.purchasingManagerList"
                      multiple
                      :multiple-limit="3"
                      collapse-tags
                      collapse-tags-tooltip
                      :max-collapse-tags="1"
                      filterable
                      default-first-option
                      :reserve-keyword="false"
                      placeholder="请选择/最多选择三人"
                      clearable>
                      <el-option v-for="item in purchasingEmpData" :label="item.empCname" :value="item.id" />
                    </el-select>
                    <span v-else>{{ scope.row.purchasingManager }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="本期有无工作内容" align="center" width="120">
                  <template #default="scope">
                    <el-switch
                      v-model="scope.row.projectWork"
                      @change="(val) => workChange(val, scope.row)"
                      active-text="有"
                      inactive-text="无" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">2、部室项目执行情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectSituationData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectSituation" label="执行情况" header-align="center" width="300">
                  <template #default="scope">
                    <el-input
                      v-model="scope.row.projectSituation"
                      type="textarea"
                      maxlength="256"
                      show-word-limit
                      :autosize="{ minRows: 2 }" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectProblem" label="存在问题" header-align="center" width="200">
                  <template #default="scope">
                    <el-input
                      v-model="scope.row.projectProblem"
                      type="textarea"
                      maxlength="256"
                      show-word-limit
                      :autosize="{ minRows: 2 }" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectSolution" label="解决措施" header-align="center" width="200">
                  <template #default="scope">
                    <el-input
                      v-model="scope.row.projectSolution"
                      type="textarea"
                      maxlength="256"
                      show-word-limit
                      :autosize="{ minRows: 2 }" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">3、部室项目工作量完成情况</span></el-row>
            <el-row class="mt-15">
              <span class="h3-font">1）询价报价情况</span><span class="h3-font-nobold">（包括总包项目和管理包项目）</span>
            </el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectInquiryQuotationData" size="small" border show-summary>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectInquiry" label="发出询价（份）" align="center" width="120">
                  <template #default="scope">
                    <el-input-number style="width: 100%" v-model="scope.row.projectInquiry" :min="0" :controls="false" size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectQuotation" label="收到报价（份）" align="center" width="120">
                  <template #default="scope">
                    <el-input-number style="width: 100%" v-model="scope.row.projectQuotation" :min="0" :controls="false" size="small" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">2）合同签订情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectContractData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectContractCount" label="合同份数" align="center" width="120">
                  <template #default="scope">
                    <el-input-number style="width: 100%" v-model="scope.row.projectContractCount" :min="0" :controls="false" size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectContractAmount" label="合同金额（万元）" header-align="center" align="right" width="140">
                  <template #default="scope">
                    <el-input-number
                      class="amount-input-number"
                      v-model="scope.row.projectContractAmount"
                      :precision="6"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">3）厂商返回设计文件的接收和提交情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectDesignDocData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="docReturnCount" label="计划返回（份）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.docReturnCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="docReceiveCount" label="实际接收（份）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.docReceiveCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="docSubmitCount" label="提交设计（份）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.docSubmitCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">4）催交和中间检验情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectDeliveryInspectionData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectOnlineDeliveryCount" label="联系催交（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectOnlineDeliveryCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectOfflineDeliveryCount" label="到场催交（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectOfflineDeliveryCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectSupervisionCount" label="驻场监造（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectSupervisionCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectInspectionCount" label="中间检验（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectInspectionCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">5）现场接保检工作情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectReceiveInspectionData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectReceiveGoodsCount" label="接货（批）" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectReceiveGoodsCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectOpenboxCount" label="开箱检验" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectOpenboxCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectSupervisionInspectionCount" label="监理报检" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectSupervisionInspectionCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectInstorageCount" label="入库" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectInstorageCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectOutstorageCount" label="出库" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectOutstorageCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectBackupHandoverCount" label="备件移交" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectBackupHandoverCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectDocArrangementCount" label="文件整理" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectDocArrangementCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectFactoryServiceCount" label="厂商服务" align="center" width="80">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectFactoryServiceCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">6）货款支付和发票收取情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectPaymentInvoiceData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectPaymentCount" label="支付申请（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectPaymentCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectApplyPassCount" label="申请批准（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectApplyPassCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectActualPayCount" label="实际付出（次）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectActualPayCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectInvoiceCount" label="收到发票（份）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectInvoiceCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectTransferFinanceCount" label="移交财务（份）" align="center" width="110">
                  <template #default="scope">
                    <el-input-number
                      style="width: 100%"
                      v-model="scope.row.projectTransferFinanceCount"
                      :precision="0"
                      :min="0"
                      :controls="false"
                      size="small" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h2-font">二、部室项目控制点执行情况</span></el-row>
            <el-row class="mt-15"><span class="h3-font">1、控制点完成情况</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectControlPointData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="本月" align="center">
                  <el-table-column prop="projectLastMonthLegacyCount" label="月前遗留" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectLastMonthLegacyCount"
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectTheMonthPlanCount" label="本月计划" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectTheMonthPlanCount"
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectAllPlanCount" label="合计计划" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectAllPlanCount"
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectCompleteCount" label="完成" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectCompleteCount"
                        @input="
                          (val) => {
                            pointCountInput(val, 'complete', scope.row);
                          }
                        "
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectUncompleteCount" label="未完" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectUncompleteCount"
                        @input="
                          (val) => {
                            pointCountInput(val, 'uncomplete', scope.row);
                          }
                        "
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectCompleteRate" label="完成率" align="center" width="60">
                    <template #default="scope">
                      <span v-if="scope.row.projectHavePoint">
                        {{ scope.row.projectCompleteRate !== null ? Number(scope.row.projectCompleteRate * 100).toFixed(0) + "%" : null }}
                      </span>
                    </template>
                  </el-table-column>
                </el-table-column>
                <el-table-column label="未完成原因" align="center">
                  <el-table-column prop="projectOwnerReasonCount" label="业主原因" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectOwnerReasonCount"
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectUpstreamReasonCount" label="上游原因" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectUpstreamReasonCount"
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="projectProfessionalReasonCount" label="专业原因" align="center" width="65">
                    <template #default="scope">
                      <el-input-number
                        v-if="scope.row.projectHavePoint"
                        style="width: 100%"
                        v-model="scope.row.projectProfessionalReasonCount"
                        :precision="0"
                        :min="0"
                        :controls="false"
                        size="small" />
                    </template>
                  </el-table-column>
                </el-table-column>
                <el-table-column label="操作" align="center" width="100">
                  <template #default="scope">
                    <el-switch
                      v-model="scope.row.projectHavePoint"
                      @change="(val) => pointChange(val, scope.row)"
                      inline-prompt
                      inactive-text="无节点"
                      width="60"
                      style="--el-switch-on-color: #13ce66" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h3-font">2、未完控制点原因说明</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectUncompleteReasonData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectMainControlContent" label="主要控制点内容" header-align="center" width="150">
                  <template #default="scope">
                    <el-input v-model="scope.row.projectMainControlContent" type="textarea" :autosize="{ minRows: 2 }" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectUncompleteReason" label="未完原因" header-align="center" width="150">
                  <template #default="scope">
                    <el-input v-model="scope.row.projectUncompleteReason" type="textarea" :autosize="{ minRows: 2 }" />
                  </template>
                </el-table-column>
                <el-table-column prop="projectSolution" label="解决措施" header-align="center" width="150">
                  <template #default="scope">
                    <el-input v-model="scope.row.projectSolution" type="textarea" :autosize="{ minRows: 2 }" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row v-if="employee.empRole === 2 || employee.empRole === 3" class="mt-15">
              <span class="h2-font">三、部室人力资源管理</span>
            </el-row>
            <el-row v-if="employee.empRole === 2 || employee.empRole === 3" class="mt-15">
              <span class="h3-font">1、部室人力资源状态</span>
            </el-row>
            <el-row v-if="employee.empRole === 2 || employee.empRole === 3" class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="employeeResourcesData" size="small" border show-summary>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="employeeType" align="center" widtn="150" />
                <el-table-column prop="regularNum" label="正式员工数量" align="center" />
                <el-table-column prop="rehireNum" label="返聘员工数量" align="center" />
                <el-table-column label="外聘员工" align="center">
                  <el-table-column prop="externalNum" label="外聘员工数量" align="center" />
                  <el-table-column prop="borrowNum" label="借用员工数量" align="center" />
                </el-table-column>
                <el-table-column prop="allNum" label="合计" align="center" />
              </el-table>
            </el-row>
            <el-row v-if="false" class="mt-15"><span class="h3-font">4、部室人力负荷情况</span></el-row>
            <el-row v-if="false" class="mt-15">
              <el-row style="width: 100%">
                <el-col :span="12"><div ref="lastMonthLoadChartRef" style="width: 100%; height: 400px"></div></el-col>
                <el-col :span="12"><div ref="theMonthLoadChartRef" style="width: 100%; height: 400px"></div></el-col>
              </el-row>
            </el-row>
            <el-row v-if="employee.empRole === 2 || employee.empRole === 3" class="mt-15">
              <span class="h2-font">四、技术及业务培训情况</span>
            </el-row>
            <el-row v-if="employee.empRole === 2 || employee.empRole === 3" class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="trainingData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="trainingDate" label="时间" align="center" width="140">
                  <template #default="scope">
                    <el-date-picker v-model="scope.row.trainingDate" style="width: 100%" />
                  </template>
                </el-table-column>
                <el-table-column prop="trainingAdress" label="地点" header-align="center" width="200">
                  <template #default="scope">
                    <el-input v-model="scope.row.trainingAdress" />
                  </template>
                </el-table-column>
                <el-table-column prop="trainingTheme" label="培训内容" header-align="center">
                  <template #default="scope">
                    <el-input v-model="scope.row.trainingTheme" />
                  </template>
                </el-table-column>
                <el-table-column prop="trainingSpeecher" label="主讲人" header-align="center" width="120">
                  <template #default="scope">
                    <el-input v-model="scope.row.trainingSpeecher" />
                  </template>
                </el-table-column>
                <el-table-column prop="trainingPartCount" label="参加人数" align="center" width="80">
                  <template #default="scope">
                    <el-input-number style="width: 100%" v-model="scope.row.trainingPartCount" :min="0" :controls="false" />
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="center" width="80">
                  <template #default="scope">
                    <span>
                      <el-text
                        v-if="scope.$index === trainingData.length - 1"
                        type="primary"
                        size="small"
                        @click="addTrainingHandle(scope)">
                        增加
                      </el-text>
                      <el-text style="margin-left: 3px" type="primary" size="small" @click="delTrainingHandle(scope)"> 删除 </el-text>
                    </span>
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
            <el-row class="mt-15"><span class="h2-font">五、下期的主要工作安排</span></el-row>
            <el-row class="mt-15"><span class="h3-font">1、项目运行过程中的主要工作</span></el-row>
            <el-row class="mt-15">
              <el-table header-cell-class-name="header-cell" :data="projectFocusData" size="small" border>
                <el-table-column type="index" label="序号" width="60" align="center" />
                <el-table-column prop="projectName" label="项目名称" header-align="center">
                  <template #default="scope">
                    <span>[{{ scope.row.projectCode }}]</span>
                    <span>{{ scope.row.projectName }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="projectFocusContent" label="重点关注的内容" header-align="center">
                  <template #default="scope">
                    <el-input v-model="scope.row.projectFocusContent" />
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
          </el-col>
          <el-col :span="2">
            <el-row style="height: 100%"></el-row>
            <el-affix v-if="empProjectData.length > 0" class="ml-15" position="bottom" :offset="40">
              <el-popover :visible="savePopoverVisible" placement="left" :width="300" :hide-after="0">
                <template #reference>
                  <el-button type="primary" size="large" @click="savePopoverVisible = true" @blur="savePopoverVisible = false">
                    保存
                  </el-button>
                </template>
                <el-row justify="space-between" align="middle" style="margin-bottom: 10px">
                  <el-col :span="1">
                    <el-icon color="#e6a23c" :size="16"><InfoFilled /></el-icon>
                  </el-col>
                  <el-col :span="22">
                    <span>
                      此操作仅会保存状态是“<span style="color: #409eff; font-weight: bold">有</span>”工作内容的项目填报信息，请谨慎操作。
                    </span>
                  </el-col>
                </el-row>
                <el-row justify="end">
                  <el-button type="info" size="small" @click="savePopoverVisible = false">再检查一下</el-button>
                  <el-button type="primary" size="small" @click="saveHandle">继续保存</el-button>
                </el-row>
              </el-popover>
            </el-affix>
          </el-col>
        </el-row>
      </el-col>
      <!-- <el-col :span="1" /> -->
    </el-row>
  </div>
  <el-dialog v-model="nullDialogVisible" title="提示" width="30%">
    <el-scrollbar max-height="400px" :always="true">
      <el-collapse v-model="activeName">
        <el-collapse-item v-for="item in nullData" :name="item.title">
          <template #title>
            <el-row justify="space-between" style="width: 100%">
              <el-row>
                <el-text type="danger" class="font-b">{{ item.title + "：" }}</el-text>
                <el-text class="font-b" size="small">{{ item.data.length + "个项目未填写" }}</el-text>
              </el-row>
              <el-text type="info">详情</el-text>
            </el-row>
          </template>
          <el-row v-for="pro in item.data">
            <el-text size="small">[{{ pro.projectCode }}]</el-text>
            <el-text size="small">{{ pro.projectName }}</el-text>
          </el-row>
        </el-collapse-item>
      </el-collapse>
    </el-scrollbar>
    <template #footer>
      <el-button type="primary" @click="nullDialogVisible = false">关闭</el-button>
    </template>
  </el-dialog>
</template>
<script setup>
import { ref, onMounted, nextTick } from "vue";
import { ElMessage, dayjs } from "element-plus";
import "dayjs/locale/zh-cn";
import * as echarts from "echarts";
import ReportService from "@/https/api/report";

// 报告期
const reportMonth = ref(dayjs(new Date()).format("YYYY-MM"));
// 项目填报情况
const reportProjectData = ref([]);
// 项目详细情况
const projectDetailsData = ref([]);
// 项目执行情况
const projectSituationData = ref([]);
// 项目询价报价情况
const projectInquiryQuotationData = ref([]);
// 项目合同签订情况
const projectContractData = ref([]);
// 厂商返回设计文件接收和提交情况
const projectDesignDocData = ref([]);
// 催交和中间检验情况
const projectDeliveryInspectionData = ref([]);
// 现场接保检工作情况
const projectReceiveInspectionData = ref([]);
// 货款支付和发票收取情况
const projectPaymentInvoiceData = ref([]);
// 项目控制点完成情况
const projectControlPointData = ref([]);
// 未完控制点原因说明
const projectUncompleteReasonData = ref([]);
// 需要删除的未完控制点原因说明
const originUncompleteReasonData = ref([]);
// 部室人力资源状态
const employeeResourcesData = ref([]);
// 技术及业务培训情况
const trainingData = ref([]);
// 项目重点关注内容
const projectFocusData = ref([]);
// 部室人力符合情况
const lastMonthLoadChartRef = ref();
let lastMonthLoadChart = {};
const lastMonthLoadData = ref({ veryFull: 16, full: 81, generally: 0, noFull: 3 });
const theMonthLoadChartRef = ref();
let theMonthLoadChart = {};
const theMonthLoadData = ref({ veryFull: 13, full: 85, generally: 0, noFull: 2 });
let monthLoadOption = {
  title: { left: "center", top: "5%" },
  legend: { orient: "vertical", top: "middle", left: "right", itemHeight: 20, textStyle: { fontSize: 13 } },
  tooltip: { trigger: "item", formatter: "{b}：{c}%" },
  series: {
    type: "pie",
    center: ["50%", "55%"], //圆心位置
    radius: "60%", //饼图半径
    label: {
      position: "outside",
      formatter: "{b}：{c}%",
      fontSize: 13,
    },
  },
  emphasis: {
    itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: "rgb(0,0,0,0.5)" },
  },
};

// 配置项目
// const selectProjectIdData = ref([]);
// const selectProjectChange = () => {
//   reportProjectData.value = reportProjectData.value.filter((project) => selectProjectIdData.value.indexOf(project.projectId) > -1);
//   let reportProjectIds = reportProjectData.value.map((project) => project.projectId);
//   for (let projectId of selectProjectIdData.value) {
//     if (reportProjectIds === null || reportProjectIds.indexOf(projectId) === -1) {
//       let project = empProjectData.value.find((item) => item.projectId === projectId);
//       let reportProject = {};
//       reportProject.projectId = project.projectId;
//       reportProject.reportMonth = dayjs(reportMonth.value).format("YYYY-MM");
//       reportProject.projectName = project.projectName;
//       reportProject.projectCode = project.projectCode;
//       reportProjectData.value.push(reportProject);
//     }
//   }
//   reportProjectData.value.sort((a, b) => {
//     return a.projectCode > b.projectCode ? 1 : -1;
//   });
// };

// const saveReportProject = () => {
//   ReportService.saveReportProject({
//     reportProjectList: reportProjectData.value,
//     reportMonth: dayjs(reportMonth.value).format("YYYY-MM"),
//   }).then((res) => {
//     if (res.code === 200) {
//       queryReport();
//     } else {
//       ElMessage.error(res.msg);
//     }
//   });
// };

// 查询项目填报情况
const queryReportLog = () => {
  ReportService.queryReportLog({ reportMonth: dayjs(reportMonth.value).format("YYYY-MM") }).then((res) => {
    if (res.code === 200 && res.data) {
      reportProjectData.value = res.data;
      // selectProjectIdData.value = reportProjectData.value.map((item) => item.projectId);
    }
  });
};

//
const collapseActiveNames = ref("");

// 当前登录用户名
let username = JSON.parse(sessionStorage.getItem("userInfo")).user.name;
// 当前登录员工个人信息
const employee = ref({});
// 当前登录员工作为采购经理所负责的项目信息
const empProjectData = ref([]);
// 采购部门员工集合
const purchasingEmpData = ref([]);
// 所有项目信息（仅主任、superuser可查）
const projectData = ref([]);
// 初始化基础数据
const initBasicData = async () => {
  await ReportService.queryEmpBasicData({ username: username }).then((res) => {
    employee.value = res.data.employee;
    empProjectData.value = res.data.empProjectList;
  });
  // 根据不同的角色显示不同的内容
  if (employee.value.empRole === 2 || employee.value.empRole === 3) {
    ReportService.queryPurchasingEmp().then((res) => {
      purchasingEmpData.value = res.data;
    });
    queryReportLog();
    // nextTick(() => {
    //   lastMonthLoadChart = echarts.init(lastMonthLoadChartRef.value);
    //   theMonthLoadChart = echarts.init(theMonthLoadChartRef.value);
    //   buildLastMonthLoad();
    //   buildTheMonthLoad();
    // });
  }
  // 如果当前登录用户作为项目经理有负责的项目，则查询其需要填报的项目
  if (empProjectData.value && empProjectData.value.length > 0) {
    queryReport();
  }
};

// 测试wcw2564、cb2353、cy2318、th2278、2023-01
// username = "wcw2564";
// reportMonth.value = "2023-01";
onMounted(() => {
  initBasicData();
});

const reportMonthChange = () => {
  if (employee.value.empRole === 2 || employee.value.empRole === 3) {
    queryReportLog();
  }
  queryReport();
};

// 节点Switch变化
const pointChange = (val, row) => {
  if (val) {
    const uncompleteReasonData = projectUncompleteReasonData.value.filter((item) => item.projectId === row.projectId);
    if (uncompleteReasonData.length === 0) {
      const uncompleteReason = {
        id: null,
        projectId: row.projectId,
        reportMonth: row.reportMonth,
        projectMainControlContent: null,
        projectUncompleteReason: null,
        projectSolution: null,
        projectName: row.projectName,
        projectCode: row.projectCode,
      };
      projectUncompleteReasonData.value.push(uncompleteReason);
      // 按项目代号排序
      projectUncompleteReasonData.value.sort((a, b) => {
        return a.projectCode > b.projectCode ? 1 : -1;
      });
    }
  } else {
    // 清空控制点完成情况数据
    row.projectLastMonthLegacyCount = null;
    row.projectTheMonthPlanCount = null;
    row.projectAllPlanCount = null;
    row.projectCompleteCount = null;
    row.projectUncompleteCount = null;
    row.projectCompleteRate = null;
    row.projectOwnerReasonCount = null;
    row.projectUpstreamReasonCount = null;
    row.projectProfessionalReasonCount = null;
    projectUncompleteReasonData.value = projectUncompleteReasonData.value.filter((item) => item.projectId !== row.projectId);
  }
};

// 工作内容Switch变化
const workChange = (val, row) => {};

const isLoading = ref(false);
// 查询报告
const queryReport = () => {
  isLoading.value = true;
  ReportService.queryReport({ reportMonth: dayjs(reportMonth.value).format("YYYY-MM"), username: username, pageStatus: "edit" }).then(
    (res) => {
      if (res.code === 200 && res.data) {
        projectDetailsData.value = res.data.projectDetails;
        isLoading.value = false;
        projectSituationData.value = res.data.projectSituation;
        projectInquiryQuotationData.value = res.data.projectInquiryQuotation;
        projectContractData.value = res.data.projectContract;
        projectDesignDocData.value = res.data.projectDesigndoc;
        projectDeliveryInspectionData.value = res.data.projectDeliveryInspection;
        projectReceiveInspectionData.value = res.data.projectReceiveInspection;
        projectPaymentInvoiceData.value = res.data.projectPaymentInvoice;
        projectControlPointData.value = res.data.projectControlPoint;
        // 提取有控制节点且完成率不是100%的项目id集合
        const projectIds = projectControlPointData.value
          .filter((item) => item.projectHavePoint && item.projectCompleteRate < 1)
          ?.map((item) => item.projectId);
        // 保留原始未完成原因数据，和保存数据对比，计算出需要删除的数据
        originUncompleteReasonData.value = res.data.projectUncompleteReason;
        // 过滤未完成控制点原因集合
        projectUncompleteReasonData.value = originUncompleteReasonData.value.filter((item) => projectIds.indexOf(item.projectId) > -1);
        employeeResourcesData.value = res.data.employeeResources;
        if (!employeeResourcesData.value || employeeResourcesData.value.length === 0) {
          employeeResourcesData.value = [
            {
              reportMonth: dayjs(reportMonth.value).format("YYYY-MM"),
              employeeType: "现场员工数量",
              regularNum: 0,
              rehireNum: 0,
              externalNum: 0,
              borrowNum: 0,
              allNum: 0,
            },
            {
              reportMonth: dayjs(reportMonth.value).format("YYYY-MM"),
              employeeType: "本部员工数量",
              regularNum: 0,
              rehireNum: 0,
              externalNum: 0,
              borrowNum: 0,
              allNum: 0,
            },
          ];
        }
        trainingData.value = res.data.training;
        if (!trainingData.value || trainingData.value.length === 0) {
          trainingData.value = [{ reportMonth: dayjs(reportMonth.value).format("YYYY-MM") }];
        }
        projectFocusData.value = res.data.projectFocus;
      }
    },
  );
};

// 构造上月人力负荷饼图
const buildLastMonthLoad = () => {
  lastMonthLoadChart && lastMonthLoadChart.clear();
  monthLoadOption.title.text = "上月－采购部人力负荷情况图";
  monthLoadOption.series.data = [
    { value: lastMonthLoadData.value.veryFull, name: "非常饱满", itemStyle: { color: "#5470c6" } },
    { value: lastMonthLoadData.value.full, name: "饱满", itemStyle: { color: "#ee6666" } },
    { value: lastMonthLoadData.value.generally, name: "一般", itemStyle: { color: "#91cc75" } },
    { value: lastMonthLoadData.value.noFull, name: "不饱满", itemStyle: { color: "#fac858" } },
  ];
  lastMonthLoadChart.setOption(monthLoadOption);
};

// 构造本月人力负荷饼图
const buildTheMonthLoad = () => {
  theMonthLoadChart && theMonthLoadChart.clear();
  monthLoadOption.title.text = "本月－采购部人力负荷情况图";
  monthLoadOption.series.data = [
    { value: theMonthLoadData.value.veryFull, name: "非常饱满", itemStyle: { color: "#5470c6" } },
    { value: theMonthLoadData.value.full, name: "饱满", itemStyle: { color: "#ee6666" } },
    { value: theMonthLoadData.value.generally, name: "一般", itemStyle: { color: "#91cc75" } },
    { value: theMonthLoadData.value.noFull, name: "不饱满", itemStyle: { color: "#fac858" } },
  ];
  theMonthLoadChart.setOption(monthLoadOption);
};

const addTrainingHandle = (scope) => {
  const row = scope.row;
  if (!(row.trainingDate || row.trainingAdress || row.trainingTheme || row.trainingSpeecher || row.trainingPartCount)) {
    ElMessage.error("当前数据行培训情况为空，不能增加");
    return;
  }
  trainingData.value.push({ reportMonth: dayjs(reportMonth.value).format("YYYY-MM") });
};

const delTrainingHandle = (scope) => {
  trainingData.value.splice(scope.$index, 1);
  if (!trainingData.value || trainingData.value.length === 0) {
    trainingData.value = [{ reportMonth: dayjs(reportMonth.value).format("YYYY-MM") }];
  }
};

const pointCountInput = (val, type, row) => {
  // 计算完成率
  if (val === null) {
    row.projectCompleteRate = 0;
  } else {
    val = Math.round(val);
    if (type === "complete" && row.projectUncompleteCount !== null && val + row.projectUncompleteCount > 0) {
      const completeRate = val / (val + row.projectUncompleteCount);
      row.projectCompleteRate = Number(completeRate).toFixed(2);
    } else if (type === "uncomplete" && row.projectCompleteCount !== null && val + row.projectCompleteCount > 0) {
      const completeRate = row.projectCompleteCount / (val + row.projectCompleteCount);
      row.projectCompleteRate = Number(completeRate).toFixed(2);
    } else {
      row.projectCompleteRate = 0;
    }
  }
  // 当本月有节点，且完成率不为100%时，需增加当前项目的未完成控制点原因说明
  if (row.projectHavePoint && row.projectCompleteRate < 1) {
    const uncompleteReasonData = projectUncompleteReasonData.value.filter((item) => item.projectId === row.projectId);
    if (uncompleteReasonData.length === 0) {
      const uncompleteReason = {
        id: null,
        projectId: row.projectId,
        reportMonth: row.reportMonth,
        projectMainControlContent: null,
        projectUncompleteReason: null,
        projectSolution: null,
        projectName: row.projectName,
        projectCode: row.projectCode,
      };
      projectUncompleteReasonData.value.push(uncompleteReason);
      // 按项目代号排序
      projectUncompleteReasonData.value.sort((a, b) => {
        return a.projectCode > b.projectCode ? 1 : -1;
      });
    }
  } else {
    projectUncompleteReasonData.value = projectUncompleteReasonData.value.filter((item) => item.projectId !== row.projectId);
  }
};

const nullDialogVisible = ref(false);
const nullData = ref([]);
const activeName = ref([]);
const savePopoverVisible = ref(false);
const saveHandle = () => {
  savePopoverVisible.value = false;

  // 全无工作不保存
  const noWorkData = projectDetailsData.value.filter((item) => item.projectWork);
  // 填报日志
  let reportLog = {};
  reportLog.reportMonth = dayjs(reportMonth.value).format("YYYY-MM");
  reportLog.empId = employee.value.id;
  reportLog.empName = employee.value.empCname;
  reportLog.username = username;

  if (noWorkData.length === 0) {
    ReportService.saveReport({
      pageStatus: "edit", // 编辑状态
      reportMonth: dayjs(reportMonth.value).format("YYYY-MM"),
      reportLog: reportLog,
      projectDetailsList: projectDetailsData.value,
      projectSituationList: null,
      projectInquiryQuotationList: null,
      projectContractList: null,
      projectDesigndocList: null,
      projectDeliveryInspectionList: null,
      projectReceiveInspectionList: null,
      projectPaymentInvoiceList: null,
      projectControlPointList: null,
      delUncompleteReasonList: null,
      projectUncompleteReasonList: null,
      employeeResourcesList: null, // 目前只拉取数据，对数据不做保存
      trainingList: null,
      projectFocusList: null,
    }).then((res) => {
      if (res.code === 200) {
        if (employee.value.empRole === 2 || employee.value.empRole === 3) {
          queryReportLog();
        }
        queryReport();
        ElMessage.success("保存成功");
      } else {
        ElMessage.error(res.msg);
      }
    });
    return;
  }

  // 非空校验
  nullData.value = [];
  // 部室项目执行情况
  let nullSituationData = projectSituationData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (!item.projectSituation || !item.projectProblem || !item.projectSolution),
  );
  if (nullSituationData.length > 0) nullData.value.push({ title: "部室项目执行情况", data: nullSituationData });
  // 询价报价情况
  let nullInquiryQuotationData = projectInquiryQuotationData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (item.projectInquiry === null || item.projectQuotation === null),
  );
  if (nullInquiryQuotationData.length > 0) nullData.value.push({ title: "询价报价情况", data: nullInquiryQuotationData });
  // 合同签订情况
  let nullContractData = projectContractData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (item.projectContractCount === null || item.projectContractAmount === null),
  );
  if (nullContractData.length > 0) nullData.value.push({ title: "合同签订情况", data: nullContractData });
  // 厂商返回设计文件的接收和提交情况
  let nullDesignDocData = projectDesignDocData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (item.docReturnCount === null || item.docReceiveCount === null || item.docSubmitCount === null),
  );
  if (nullDesignDocData.length > 0) nullData.value.push({ title: "厂商返回设计文件的接收和提交情况", data: nullDesignDocData });
  // 催交和中间检验情况
  let nullDeliveryInspectionData = projectDeliveryInspectionData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (item.projectOnlineDeliveryCount === null ||
        item.projectOfflineDeliveryCount === null ||
        item.projectSupervisionCount === null ||
        item.projectInspectionCount === null),
  );
  if (nullDeliveryInspectionData.length > 0) nullData.value.push({ title: "催交和中间检验情况", data: nullDeliveryInspectionData });
  // 现场接保检工作情况
  let nullProjectReceiveInspectionData = projectReceiveInspectionData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (item.projectReceiveGoodsCount === null ||
        item.projectOpenboxCount === null ||
        item.projectSupervisionInspectionCount === null ||
        item.projectInstorageCount === null ||
        item.projectOutstorageCount === null ||
        item.projectBackupHandoverCount === null ||
        item.projectDocArrangementCount === null ||
        item.projectFactoryServiceCount === null),
  );
  if (nullProjectReceiveInspectionData.length > 0)
    nullData.value.push({ title: "现场接保检工作情况", data: nullProjectReceiveInspectionData });
  // 货款支付和发票收取情况
  let nullPaymentInvoiceData = projectPaymentInvoiceData.value.filter(
    (item) =>
      projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork &&
      (item.projectPaymentCount === null ||
        item.projectApplyPassCount === null ||
        item.projectActualPayCount === null ||
        item.projectInvoiceCount === null ||
        item.projectTransferFinanceCount === null),
  );
  if (nullPaymentInvoiceData.length > 0) nullData.value.push({ title: "货款支付和发票收取情况", data: nullPaymentInvoiceData });
  // 控制点完成情况
  let nullControlPointData = projectControlPointData.value.filter(
    (item) =>
      item.projectHavePoint &&
      (item.projectLastMonthLegacyCount === null ||
        item.projectTheMonthPlanCount === null ||
        item.projectAllPlanCount === null ||
        item.projectCompleteRate === null ||
        item.projectOwnerReasonCount === null ||
        item.projectUpstreamReasonCount === null ||
        item.projectProfessionalReasonCount === null),
  );
  if (nullControlPointData.length > 0) nullData.value.push({ title: "控制点完成情况", data: nullControlPointData });
  // 未完控制点原因说明
  let nullProjectUncompleteReasonData = projectUncompleteReasonData.value.filter(
    (item) => !item.projectMainControlContent || !item.projectUncompleteReason || !item.projectSolution,
  );
  if (nullProjectUncompleteReasonData.length > 0)
    nullData.value.push({ title: "未完控制点原因说明", data: nullProjectUncompleteReasonData });
  // 项目运行过程中的主要工作
  let nullProjectMainWorkData = projectFocusData.value.filter(
    (item) => projectDetailsData.value.find((details) => details.projectId === item.projectId)?.projectWork && !item.projectFocusContent,
  );
  if (nullProjectMainWorkData.length > 0) nullData.value.push({ title: "项目运行过程中的主要工作", data: nullProjectMainWorkData });

  // 如果未填数据大于0则弹出提示
  if (nullData.value.length > 0) {
    activeName.value = [];
    nextTick(() => {
      nullDialogVisible.value = true;
    });
    return;
  }

  const trainingList = trainingData.value.filter(
    (item) => item.id || item.trainingDate || item.trainingAdress || item.trainingTheme || item.trainingSpeecher || item.trainingPartCount,
  );
  // 需要保存的未完控制点原因说明数据与原始数据对比，计算出需要删除的数据
  const projectIds = projectUncompleteReasonData.value.map((item) => item.projectId);
  const delUncompleteReasonData = originUncompleteReasonData.value.filter((item) => projectIds.indexOf(item.projectId) < 0);

  ReportService.saveReport({
    pageStatus: "edit", // 编辑状态
    reportMonth: dayjs(reportMonth.value).format("YYYY-MM"),
    reportLog: reportLog,
    projectDetailsList: projectDetailsData.value,
    projectSituationList: projectSituationData.value,
    projectInquiryQuotationList: projectInquiryQuotationData.value,
    projectContractList: projectContractData.value,
    projectDesigndocList: projectDesignDocData.value,
    projectDeliveryInspectionList: projectDeliveryInspectionData.value,
    projectReceiveInspectionList: projectReceiveInspectionData.value,
    projectPaymentInvoiceList: projectPaymentInvoiceData.value,
    projectControlPointList: projectControlPointData.value,
    delUncompleteReasonList: delUncompleteReasonData,
    projectUncompleteReasonList: projectUncompleteReasonData.value,
    employeeResourcesList: null, // 目前只拉取数据，对数据不做保存
    trainingList: trainingList,
    projectFocusList: projectFocusData.value,
  }).then((res) => {
    if (res.code === 200) {
      if (employee.value.empRole === 2 || employee.value.empRole === 3) {
        queryReportLog();
      }
      queryReport();
      ElMessage.success("保存成功");
    } else {
      ElMessage.error(res.msg);
    }
  });
};
</script>
<style scoped>
.mb-15 {
  margin-bottom: 15px;
}
.mt-15 {
  margin-top: 15px;
}
.ml-15 {
  margin-left: 15px;
}
.h1-font {
  font-size: 26px;
  font-weight: bold;
}
.h2-font {
  font-size: 20px;
  font-weight: bold;
}
.h3-font {
  font-size: 16px;
  font-weight: bold;
}
.h3-font-nobold {
  font-size: 16px;
}
.el-table :deep() .header-cell {
  background: #f5f7fa !important;
}
.amount-input-number {
  width: 100%;
}
.amount-input-number :deep() .el-input__inner {
  text-align: right;
}
.font-b {
  font-weight: bold;
}
</style>
